package cn.stylefeng.guns.modular.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.stylefeng.guns.modular.entity.IdjImages;
import cn.stylefeng.guns.modular.mapper.IdjImagesMapper;
import cn.stylefeng.guns.modular.service.IIdjImagesService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author TANGWJ
 * @since 2020-08-08
 */
@Service
public class IdjImagesServiceImpl extends ServiceImpl<IdjImagesMapper, IdjImages> implements IIdjImagesService {

	@Autowired
	private IdjImagesMapper mapper;
	
	@Override
	public IdjImages edit(Long id) {
		IdjImages images = mapper.selectByKeyId(id);
        return images;
	}

	@Override
	public int setStatus(IdjImages images) {
		return mapper.setStatus(images);
	}

	@Override
	public int insert(IdjImages images) {
		return mapper.insert(images);
	}

	@Override
	public ModelAndView getList(Integer type) {
		IdjImages images = new IdjImages();
		List<IdjImages> list = mapper.getList(type);
		if (list.size() == 1) {
			images = list.get(0);
		}else{
			images.setCount(list.size());
			images.setImglist(list);
		}
		ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("images", images);
        return modelAndView;
	}
}
